
<template>
	<view class="user-order">
		<tabs :active="active" @change="changeShow" :config="{itemWidth: 150}">
			<tab v-for="(item, index) in order" :key="index" :title="item.name" :name="item.type">
				<order-list v-if="item.isShow" :order-type="item.type" :ref="'order' + item.type"></order-list>
			</tab>
		</tabs>
		<!-- <float-tab></float-tab> -->
	</view>
</template>

<script>
	import {
		orderType
	} from '@/utils/type';

	export default {
		data() {
			return {
				active: orderType.ALL,
				order: [{
					name: 'Tất cả',
					type: orderType.ALL,
					isShow: false
				}, {
					name: 'Vận chuyển',
					type: orderType.DELIVERY,
					isShow: false
				}, {
					name: 'Đã hoàn thành',
					type: orderType.FINISH,
					isShow: false
				}, {
					name: 'Đóng cửa',
					type: orderType.CLOSE,
					isShow: false
				}]
			};
		},

		components: {},
		props: {},
		onLoad: function(options) {
			const {
				order
			} = this
			let type = options.type || orderType.ALL;
			let index = order.findIndex(item => item.type == type)
			this.changeShow(index);
		},

		onPullDownRefresh: function() {
			const {
				active,
				order
			} = this
			console.log(this.$refs['order' + order[active].type])
			this.$refs['order' + order[active].type][0].reflesh()
		},

		onReachBottom: function() {
			const {
				active,
				order
			} = this
			console.log(this.$refs['order' + order[active].type])
			this.$refs['order' + order[active].type][0].getOrderListFun()
		},
		methods: {
			changeShow(index) {
				if (index != -1) {
					this.active = index
					this.order[index].isShow = true
				}
			},
		}
	};
</script>
<style>

</style>